package cn.script.fxj.bind.utils;

import javafx.beans.property.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class BindPropertyUtils {

    public static Property getProperty(Class<?> type) {
        if (type.equals(String.class)) {
            return new SimpleStringProperty();
        }
        if (type.equals(Integer.class) || type.equals(int.class)) {
            return new SimpleIntegerProperty();
        }
        if (type.equals(Long.class) || type.equals(long.class)) {
            return new SimpleLongProperty();
        }
        if (type.equals(Double.class) || type.equals(double.class)) {
            return new SimpleDoubleProperty();
        }
        if (type.equals(Float.class) || type.equals(Float.class)) {
            return new SimpleFloatProperty();
        }
        if (type.equals(Boolean.class) || type.equals(boolean.class)) {
            return new SimpleBooleanProperty();
        }
        if (List.class.isAssignableFrom(type)) {
            return new SimpleListProperty();
        }
        if (Set.class.isAssignableFrom(type)) {
            return new SimpleSetProperty();
        }
        if (Map.class.isAssignableFrom(type)) {
            return new SimpleMapProperty();
        }
        return null;
    }
}
